package com.sprouting.personal.model.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.sprouting.personal.annotations.CheckLength;
import com.sprouting.personal.annotations.CheckNotNull;
import com.sprouting.personal.model.common.BaseModel;
import com.sprouting.personal.model.common.jsr.AddGroup;
import com.sprouting.personal.model.common.jsr.UpdGroup;
import lombok.Data;

import javax.validation.constraints.Null;

/**
 * 字典
 *
 * @author ：LX（长沙麓谷）
 * @date 创建时间： 2022/7/29 8:32
 */
@TableName("ps_dict")
@Data
public class Dict extends BaseModel {

    /**
     * 主键
     */
    @TableId
    @CheckNotNull(message = "非法ID", groups = UpdGroup.class)
    @Null(message = "无效ID", groups = AddGroup.class)
    private String id;
    /**
     * 字典组ID
     * @see DictGroup#getId()
     */
    @CheckNotNull(message = "请选择绑定的字典组")
    private String groupId;
    /**
     * 用户ID ，默认用户ID为 {@link com.sprouting.personal.interfaces.common.Constant.DefaultValue#STRING}，则为公共字典
     * 其他有值的则都为非基础数据
     * @see User#getId()
     */
    @CheckNotNull(message = "请选择所属用户", groups = UpdGroup.class)
    private String userId;
    /**
     * 字典编号-字典组+00x 同组内有且唯一
     */
    @CheckLength(min = 1, max = 15, message = "字典代码超过长度限制")
    @CheckNotNull(message = "请输入字典代码")
    private String code;
    /**
     * 字典名称
     */
    @CheckLength(min = 1, max = 150, message = "字典名称超过长度限制")
    @CheckNotNull(message = "请输入字典名称")
    private String name;
    /**
     * 数据值
     */
    @CheckLength(min = 1, max = 300, message = "字典数据值超过长度限制")
    @CheckNotNull(message = "请输入字典数据值")
    private String value;
    /**
     * 是否基础数据
     * @see com.sprouting.personal.interfaces.common.Constant.BaseData
     */
    private Integer baseData;
    /**
     * 备注
     */
    @CheckLength(max = 255, message = "备注超过长度限制")
    private String remarks;
    /**
     * 排序,默认99
     * @see com.sprouting.personal.interfaces.common.Constant.DefaultValue#SORT
     */
    private Double sort;
}
